@use "~@mdn/minimalist/sass/mixins/utils" as *;
@use "../../../ui/vars" as *;

// Style for mobile *and* desktop.

.bc-table {
  width: 100%;
  margin: 1rem 0;
  border: 1px solid var(--border-primary);
  border-radius: var(--elem-radius);
  border-collapse: separate;
  border-spacing: 0;

  td,
  th {
    border: 1px solid var(--border-secondary);
    border-width: 0 0 1px 1px;
    font: var(--type-body-m);
    padding: 0.4rem;

    &[aria-expanded="false"] {
      height: 2rem;
    }

    code {
      font-size: 0.75rem !important;
    }
  }

  // these props allow us to add border-radius to the table.
  // border-collapse: separate gets in the way of this
  // being easy.
  tbody {
    tr {
      height: 3rem;

      &:last-child {
        th,
        td {
          border-bottom-width: 0;
        }
      }

      th {
        border-left-width: 0;
        vertical-align: middle;
      }
    }

    .bc-support {
      button {
        cursor: pointer;
        width: 100%;
      }

      &.bc-supports-no > button > span {
        color: var(--text-primary-red);
      }
      &.bc-supports-partial > button > span {
        color: var(--text-primary-yellow);
      }
      &.bc-supports-preview > button > span {
        color: var(--text-primary-blue);
      }
      &.bc-supports-yes > button > span {
        color: var(--text-primary-green);
      }
    }
  }

  th {
    vertical-align: bottom;
    background: var(--background-tertiary);
  }

  .bc-supports {
    margin-bottom: 1rem;

    .icon-wrap {
      background: var(--background-primary);
    }
  }

  .icon-wrap {
    .bc-support-level {
      @include visually-hidden;
    }
  }
  .bc-support {
    > button > .icon-wrap {
      display: block;
    }
  }
}

.bc-head-txt-label {
  -ms-writing-mode: tb-rl;
  -webkit-writing-mode: vertical-rl;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
}

.bc-support {
  text-align: center;
  vertical-align: middle;
}

.bc-level-no {
  background-color: var(--icon-critical);
}

.bc-level-preview {
  background-color: var(--icon-information);
}

.bc-legend-items-container {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 2rem;
  font: var(--type-body-m);
}

.bc-legend-item {
  display: flex;
  gap: 0.5rem;
}
.bc-legend-item-dt {
  display: flex;

  .icon {
    background-color: var(--icon-secondary);
  }
}

// Row with desktop / mobile icons.
.bc-platforms {
  height: 2rem;

  th {
    text-align: center;
  }

  td {
    border: none;
  }
}

// Row with browser names.
.bc-browsers {
  th {
    text-align: center;
  }

  td {
    border-width: 0 0 1px 0;
  }
}

.bc-notes-list {
  position: relative;
  margin: 0.5rem 0;
  text-align: left;
  width: 100%;

  &:before {
    position: absolute;
    z-index: -1;
    height: 100%;
    left: 7px;
    width: 2px;
    background: var(--border-primary);
    content: "";
  }

  // complicated selector to cover the last bit of the grey line above.
  .bc-notes-wrapper:last-child dd:last-child {
    position: relative;

    &:before {
      position: absolute;
      z-index: -1;
      height: calc(100% - 6px);
      left: 7px;
      width: 2px;
      bottom: 0;
      background: var(--background-primary);
      content: "";
    }
  }

  .bc-level-yes.icon.icon-yes {
    // override icon
    background-color: var(--icon-success);
    mask-image: url("../../../assets/icons/yes-circle.svg");
  }

  .icon.icon-footnote {
    mask-image: none;
    border-radius: 50%;
    border: 3px solid var(--background-primary);
    background: var(--border-primary);
  }

  .icon.icon-disabled {
    background-color: var(--icon-information);
  }

  .bc-version-label {
    display: inline;
    font-weight: 650;
  }

  abbr {
    margin-right: 4px;
  }

  dd {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
    text-indent: -1.5rem;

    &:last-child {
      margin-bottom: 2rem;
    }
  }
}

.bc-notes-wrapper {
  margin-bottom: 1rem;

  &:last-child {
    margin-bottom: 0;
  }
}

dl.bc-notes-list {
  dt.bc-supports {
    margin-top: 1rem;
  }
  dd.bc-supports-dd {
    margin-bottom: 1rem;
  }
}

.offscreen,
.only-icon span {
  @include visually-hidden();
}

.bc-table-row-header {
  width: 100%;
  display: inline-flex;
  align-items: baseline;

  code {
    overflow: hidden;
    font-size: 0.75rem;
  }

  .left-side,
  .right-side {
    white-space: pre;
    overflow: hidden;
  }

  /* Can only flex-shrink and not flex-grow
  ie the "slider" in a sliding glass door */
  .left-side {
    flex: 0 1 auto;
    text-overflow: ellipsis;
  }
  /* Can flex-grow and not flex-shrink as
  its the stationary portion */
  .right-side {
    flex: 1 0 auto;
  }

  .bc-icons {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.25rem;
    .icon {
      background-color: var(--icon-secondary);
      &:hover {
        background-color: var(--icon-primary);
      }
    }
  }
}

.bc-github-link {
  font: var(--type-body-m);
}

.main-page-content {
  .bc-legend {
    dd,
    dt {
      margin-top: 0;
      margin-bottom: 0;
      margin-left: 0;
    }
  }
  .bc-supports-dd {
    margin: 0;
  }
}

@import "./index-mobile";
@import "./index-desktop";
@import "./index-desktop-md";
@import "./index-desktop-lg";
